import { getToken } from '@/utils/cookie'


export default function ({ route, next, store }) {
    // console.log(arguments[0])
    const whileList = ['/login', '/newLogin']
    const token = getToken()

    // console.log(token)
    if (token) {
        const hasRoles = store.getters.roles && store.getters.roles.length > 0
        console.log(hasRoles)
        if (hasRoles) {
            // Todo
            // next()
        } else {
            store.dispatch('users/getUserInfo', token)
        }
    } else {
        if (whileList.includes(route.path)) {
            // next()
        } else {
            next({ path: '/login', })
        }
    }


}